//
//  MoreSettingViewController.m
//  TeacherNet
//
//  Created by slz on 2018/1/3.
//  Copyright © 2018年 bnsr. All rights reserved.
//

#import "MoreSettingViewController.h"
#import "MFWUserLoginManager.h"

@interface MoreSettingTableViewCell : UITableViewCell
@property (nonatomic,strong) UILabel*mLabel;
@end
@implementation MoreSettingTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        _mLabel = [UILabel new];
        [self.contentView addSubview:_mLabel];
        _mLabel.textColor = kDark_TextColor_Default;
        _mLabel.fontSize = kFont_Size_Middle_Title;
        [_mLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).offset(20);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
        }];
        
        UIView * lineView = [UIView quickLineColorView];
        [self.contentView addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.and.bottom.mas_equalTo(self.contentView);
            make.height.mas_equalTo(.5);
        }];
    }
    return self;
}
@end


@interface MoreSettingViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UILabel *versionLabel;
@property (nonatomic,strong) NSArray *titles;
@end

@implementation MoreSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.showNavigationBar = YES;
    [self setControllerTitle:@"设置"];
    _titles = @[@"给个好评",@"意见反馈",@"用户协议"];
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"back_icon" selectImage:nil addTarget:self andAction:@selector(backAction)];
    self.view.backgroundColor = [UIColor colorWithRGB:0xF0F0F4];
    
    NSString * version = [MFWSdkEnvironment sharedInstance].appVersion;
    _versionLabel.text = [NSString stringWithFormat:@"百年树人 %@",version];
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * resuerIdentifier = @"MoreSettingTableViewCell";
    MoreSettingTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:resuerIdentifier];
    if (!cell){
        cell = [[MoreSettingTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:resuerIdentifier];
    }
    cell.mLabel.text = _titles[indexPath.row];
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _titles.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}



- (void)backAction{
    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)logout:(id)sender {
    [[MFWUserLoginManager sharedInstance] logout];
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
